/**
@author		Jong Min, Lee
@date		  10/01/2014
@breif		Study set class and Producer class 

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#pragma once

#include <vector>

#include "Taurus_Util/Macros.h"
#include "Taurus_DcmData/Defines.h"

//forward declarations
class CStudy;

/**
@brief		study set open mode
*/
enum StudySetOpenMode
{
  StudySetOpenModeFirstInvalid,
  StudySetOpenModeNormal,           //open normally
  StudySetOpenModeWithRltStudies,   //open with related studies
  StudySetOpenModeSeries,           //open selected series
  StudySetOpenModeStack,            // stack open
  StudySetOpenModeLastInvalid
};

/**
@brief		study set class
*/
class TAURUS_DCMDATA_EXPORT CStudySet
{
private:
  /**
  @brief		default constructor
  */
  CStudySet();

  DISALLOW_COPY_AND_ASSIGN(CStudySet);

public:
  friend class CStudySetProducer;

  /**
  @brief		destructor
  */
  ~CStudySet();

  /**
  @brief		get pointer to primary study
  @return		pointer to primary study
  */
  CStudy* getPrimaryStudy() const;

  /**
  @brief		get the number of study
  @return		the number of studies
  */
  unsigned getNumStudies() const;

  /**
  @brief		access to a study
  @param		index the index number of study to be accessed
  @return		pointer to study if found, nullptr if not
  */
  CStudy* getStudy(const unsigned index) const;

private:
  /**
  @brief		initialize study set
  */
  void init();

  /**
  @brief		destroy this. this function should be only used in destructor
  */
  void destroy();

  /**
  @brief		remove all studies
  @return		
  */
  void removeAllStudies();

private:
  //open mode
  StudySetOpenMode m_theOpenMode;

  //pointer to primary study
  CStudy* m_thePrimaryStudy;

  //pointer to the studies belong to study set
  std::vector<CStudy*> m_theStudies;
};

/**
@brief		study set producer
*/
class TAURUS_DCMDATA_EXPORT CStudySetProducer
{
public:
  /**
  @brief		
  @param		
  @return		
  */
  static DWORD produce(CStudy** studies,
                       const unsigned numStudies,
                       const unsigned primaryIndex,
                       StudySetOpenMode openMode,
                       CStudySet*& outStudySet);
};